home *** CD-ROM | disk | FTP | other *** search
- class disney.rabbitRivalry.ents.Tree extends disney.rabbitRivalry.ents.Entity
- {
- var __baseY;
- var __trunkHeight;
- var startY;
- var isDrawn;
- var __xOnscreen;
- var x;
- var scale;
- var baseWidth;
- var mc;
- var y;
- var __fastScale;
- var z;
- var startScale;
- var baseHeight;
- var isTreeTopDrawn;
- var isTreeTrunkDrawn;
- var hdWidth;
- var hdReg;
- var TYPE = "tree";
- var DRAWTYPE = "trees";
- var __DEF_ASSET = "_empty";
- var __DEF_WIDTH = 521;
- var __DEF_HEIGHT = 93;
- var __USE_ACTUAL_DIMENSIONS = false;
- var __USE_DIMENSIONS_AS_HD = true;
- var __TREETOP_ASSET = "treetop_mc";
- var __TREETRUNK_ID = "treetrunk_mc";
- var __TRUNK_WIDTH_HALF = 125;
- var __SHADOW_START = 80;
- var __SHADOW_WIDTH = 40;
- var __TREETOP_HEIGHT = 50;
- function Tree(t_data)
- {
- super(t_data);
- if(t_data.ground == undefined)
- {
- this.__baseY = 700;
- }
- else
- {
- this.__baseY = t_data.ground;
- }
- this.__baseY -= 23;
- this.__trunkHeight = this.__baseY - this.startY;
- }
- function updateAnim()
- {
- }
- function render(camera, dt)
- {
- if(!this.isDrawn)
- {
- this.updateDraw(camera);
- }
- this.__xOnscreen = Math.abs((this.x - camera.x) * this.scale) < camera.sc.x + this.baseWidth;
- this.renderTreeTrunk(camera,this.__xOnscreen);
- this.renderTreeTop(camera,this.__xOnscreen);
- this.mc._x = Math.ceil(((this.x - camera.x) * this.scale + camera.sc.x) * 100) / 100;
- this.mc._y = Math.ceil(((this.y - camera.y) * this.scale + camera.sc.y) * 100) / 100;
- this.__fastScale = camera.fl / (this.z - camera.z);
- if(this.scale != this.__fastScale)
- {
- this.scale = this.__fastScale;
- this.mc._xscale = this.mc._yscale = 100 * (1 + (this.scale - this.startScale));
- }
- }
- function renderTreeTop(camera, xOnscreen)
- {
- if(xOnscreen && Math.abs((this.y - camera.y) * this.scale) < camera.sc.y + this.baseHeight)
- {
- if(!this.isTreeTopDrawn)
- {
- this.mc.attachMovie(this.__TREETOP_ASSET,this.__TREETOP_ASSET,2);
- this.mc[this.__TREETOP_ASSET].cacheAsBitmap = true;
- this.isTreeTopDrawn = true;
- }
- }
- else if(this.isTreeTopDrawn)
- {
- this.mc[this.__TREETOP_ASSET].removeMovieClip();
- this.isTreeTopDrawn = false;
- }
- }
- function renderTreeTrunk(camera, xOnscreen)
- {
- if(xOnscreen)
- {
- if(!this.isTreeTrunkDrawn)
- {
- var _loc2_ = this.mc.createEmptyMovieClip(this.__TREETRUNK_ID,1);
- var _loc3_ = 8480297;
- if(disney.rabbitRivalry.GameState.getInstance().levelNum > 5)
- {
- _loc3_ = 4930840;
- }
- _loc2_.lineStyle(1,_loc3_,100);
- _loc2_.beginFill(_loc3_,100);
- _loc2_.moveTo(- this.__TRUNK_WIDTH_HALF,this.__trunkHeight);
- _loc2_.lineTo(this.__TRUNK_WIDTH_HALF,this.__trunkHeight);
- _loc2_.lineTo(this.__TRUNK_WIDTH_HALF,this.__TREETOP_HEIGHT);
- _loc2_.lineTo(- this.__TRUNK_WIDTH_HALF,this.__TREETOP_HEIGHT);
- _loc2_.lineTo(- this.__TRUNK_WIDTH_HALF,this.__trunkHeight);
- _loc3_ = 7954728;
- if(disney.rabbitRivalry.GameState.getInstance().levelNum > 5)
- {
- _loc3_ = 5982494;
- }
- _loc2_.beginFill(_loc3_,100);
- _loc2_.moveTo(this.__SHADOW_START,this.__trunkHeight);
- _loc2_.lineTo(this.__SHADOW_START + this.__SHADOW_WIDTH,this.__trunkHeight);
- _loc2_.lineTo(this.__SHADOW_START + this.__SHADOW_WIDTH,this.__TREETOP_HEIGHT);
- _loc2_.lineTo(this.__SHADOW_START,this.__TREETOP_HEIGHT);
- _loc2_.lineTo(this.__SHADOW_START,this.__trunkHeight);
- _loc2_.cacheAsBitmap = true;
- this.isTreeTrunkDrawn = true;
- }
- }
- else if(this.isTreeTrunkDrawn)
- {
- this.mc[this.__TREETRUNK_ID].removeMovieClip();
- this.isTreeTrunkDrawn = false;
- }
- }
- function updateDraw(camera)
- {
- smashing.keithm.Viewport.getInstance().draw({element:this});
- this.isTreeTopDrawn = false;
- this.isTreeTrunkDrawn = false;
- }
- function runHD(player)
- {
- if(player.nextX > this.x - this.hdWidth && player.nextX < this.x + this.hdWidth)
- {
- if(player.velocity.y > 0 && player.y < this.y + 45 && player.nextY >= this.y)
- {
- trace("Tree collision : " + this.y);
- return true;
- }
- }
- return false;
- }
- function setHDRegistration()
- {
- this.hdReg = {};
- this.hdReg.x = 0;
- this.hdReg.y = 0;
- }
- }
-